<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="" rel="stylesheet" type="text/css">
</head>
<body>
    <script>
        var str="abasdfgsaa";
       var obj={},reslut=[];
        for(var i=0;i<str.length;i++)
        {
            if(reslut.indexOf(str[i])<0)
            {
                obj[str[i]]=1;
                reslut.push(str[i]);
            }
            else
                  obj[str[i]]+=1;
        }
        console.log(obj);
        
        var b=1;
        function a(b) {
            b=2;
            alert(b);
        }
        a(b);//2
        alert(b);//1
    </script>
</body>
</html>